package com.example.springboot.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author：伐柯梦姝
 * @Package：com.example.springboot.common
 * @Project：springboot
 * @name：Result
 * @Date：2025/2/3 23:52
 * @Filename：Result
 * @for:
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Result {
       //静态属性
       private static final String SUCCESS = "0";
       private static final String ERROR = "-1";

       //类的属性
       private String code;
       private String msg;
       private Object data;

       public static Result success(){
              Result result = new Result();
              result.setCode(SUCCESS);
              return result;
       }

       public static Result success(Object data){
              Result result = new Result();
              result.setCode(SUCCESS);
              result.setData(data);
              return result;
       }

       public static Result error(String msg){
              Result result = new Result();
              result.setCode(ERROR);
              result.setMsg(msg);
              return result;
       }

}
